package com.air.ota.vo;

import com.air.ota.util.ConfigProperties;
import com.air.ota.util.HexStringUtil;
import com.air.ota.util.PBOCUtil;

public class UTKRegResponseDownlinkVO extends  UTKBaseDownlinkVO{
	
	
	protected byte[] cardAppSequence;
	protected byte[] regSequence;
	protected byte[] outerAuthCode;
	protected byte[] cardEffectTime;
	protected byte[] cardExpireTime;
	
	//protected byte[] mac1;
	protected byte[] deviceNum;
	
	
	
	
	
	public UTKRegResponseDownlinkVO(byte[] cardSequence,byte[] pkgSequence,
			byte[] cardAppSequence,byte[] regSequence,byte[] outerAuthCode
			,byte[] cardEffectTime,byte[] cardExpireTime){
		super(cardSequence,pkgSequence);
		this.cmdType = 0x15;
		
		this.cardAppSequence = cardAppSequence;
		this.regSequence = regSequence;
		this.outerAuthCode = outerAuthCode;
		this.cardEffectTime = cardEffectTime;
		this.cardExpireTime  = cardExpireTime;
		
		
		
		/*
		byte[] macData = new byte[14];
		System.arraycopy(cardEffectTime, 0, macData, 0, 7);
		System.arraycopy(cardExpireTime, 0, macData, 7, 7);
		PBOCUtil pbocUtil= new PBOCUtil();
		byte[] outerAuthKey = HexStringUtil.hexStringToBytes(ConfigProperties.getInstance().getValue("utk.outerAuthKey"));
		this.mac1=pbocUtil.Mac(outerAuthKey, macData, HexStringUtil.hexStringToBytes("0000000000000000"));
		*/
		
		this.deviceNum = HexStringUtil.hexStringToBytes(ConfigProperties.getInstance().getValue("szt.terminalNum"));
		
		String cmdDataHexString=HexStringUtil.bytesToHexString(this.cardAppSequence)+
				HexStringUtil.bytesToHexString(this.regSequence)+
				HexStringUtil.bytesToHexString(this.outerAuthCode)+
				HexStringUtil.bytesToHexString(this.cardEffectTime)+
				HexStringUtil.bytesToHexString(this.cardExpireTime)+
				HexStringUtil.bytesToHexString(this.deviceNum)+
				HexStringUtil.bytesToHexString(this.pkgSequence);
		
		
		this.cmdData = HexStringUtil.hexStringToBytes(cmdDataHexString);
		
		
	}
	
}
